#include "../../../libraries/sockets/tcp_client.h"
#include <iostream>
#include <fstream>
#include <string>
#include "../../../config.h"

#include <cstdlib>

using namespace std;

int main(int argc, char *argv[])

{
    if (argc<3)
    {
        cout <<"use this format: ./server IP portno" <<endl;
        exit(1);
    }

    TCP_client client(argv[1], atoi (argv[2]));


    enum oper{Sm, Rs, Dv, Mp, Ex,Rz };
    if (argc<3)
    {
        cout <<"use this format: ./server IP portno" <<endl;
        exit(1);
    }

    
    string op, num1,num2, message1, message2, resultado;

    cout << "[Sm]Suma, [Rs]Resta, [Dv]División, [Mp]Multiplicación, [Ex]Exponente, [Rz]Raiz" << endl;
    cin >> op;
    char ope[2];
	if (op=="Sm" ) sprintf(ope,"%d", Sm);
	else if (op=="Rs" ) sprintf(ope,"%d", Rs);
	else if (op=="Dv" ) sprintf(ope,"%d", Dv);
	else if (op=="Mp" ) sprintf(ope,"%d", Mp);
	else if (op=="Ex" ) sprintf(ope,"%d", Ex);
	else if (op=="Rz" ) sprintf(ope,"%d", Rz);

    client << ope;

    client >> message1;
    cout << message1;

    cin >> num1;
    client << num1;



    if(op!="Rz")
    {
	client >> message2;
        cout << message2;
        cin >> num2;
        client << num2;
    }

    client >> resultado;
    cout << "Resultado: " << resultado << endl;

    return 0;
}
